home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Mac Game Programming Gurus
/
TricksOfTheMacGameProgrammingGurus.iso
/
Book Chapters
/
10 - Networking
/
NovelNetwar
/
myabout.c
< prev
next >
Wrap
Text File
|
1995-05-12
|
4KB
|
188 lines
// My way-cool about box!
#include "NovelNetwar.h"
#define QixLength 50
static void CenterWindow(WindowPtr wPtr);
static void CenterWindow(WindowPtr wPtr)
{
int screenWidth,screenHeight,windowWidth,windowHeight,left,top;
if (wPtr == 0L)
return;
screenWidth = qd.screenBits.bounds.right - qd.screenBits.bounds.left;
screenHeight = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top - 20;
windowWidth = wPtr->portRect.right - wPtr->portRect.left;
windowHeight = wPtr->portRect.bottom - wPtr->portRect.top + 20;
left = qd.screenBits.bounds.left + (screenWidth - windowWidth)/2;
top = qd.screenBits.bounds.top + 20 + (screenHeight - windowHeight)/2;
if (left < 0)
left = 0;
if (top < 40)
top = 40;
MoveWindow(wPtr,left,top,FALSE);
}
void DoAboutBox(int doWait)
{
Rect creditRect, lineRect;
GrafPtr oldPort;
WindowPtr creditWPtr;
EventRecord theEvent;
long iticks;
char *line1 = VERSION;
char *line2 = "Written by Roy Wood";
char *line3 = "©1995 Silicon Angst Software";
char *line4 = "122 Britannia Avenue";
char *line5 = "London, Ontario, Canada N6H 2J5";
char *line6 = "(416) 694-5927";
char *line7 = "rrwood@io.org";
int count,i;
int x[4],y[4],vx[4],vy[4],length,deltay,deltax;
long finalTicks;
GetPort(&oldPort);
SetRect(&creditRect, 75,75,425,220);
creditWPtr = NewWindow((WindowPeek) 0L, &creditRect, (ConstStr255Param) "\1x", FALSE, dBoxProc, (WindowPtr) -1L, FALSE, 0L);
SetPort(creditWPtr);
CenterWindow(creditWPtr);
ShowWindow(creditWPtr);
MAIN:
BeginUpdate(creditWPtr);
EndUpdate(creditWPtr);
creditRect = creditWPtr->portRect;
SetRect(&lineRect, 100,10,350,25);
BackPat(&(qd.black));
EraseRect(&creditRect);
TextMode(srcXor);
TextSize(12);
TextFont(3);
TextFace(bold);
TextBox(line1, strlen(line1), &lineRect, teJustCenter);
OffsetRect(&lineRect, 0 , 20);
TextSize(10);
TextBox(line2, strlen(line2), &lineRect, teJustCenter);
TextFace(0);
OffsetRect(&lineRect, 0 , 25);
TextBox(line3, strlen(line3), &lineRect, teJustCenter);
OffsetRect(&lineRect, 0 , 15);
TextBox(line4, strlen(line4), &lineRect, teJustCenter);
OffsetRect(&lineRect, 0 , 15);
TextBox(line5, strlen(line5), &lineRect, teJustCenter);
OffsetRect(&lineRect, 0 , 15);
TextBox(line6, strlen(line6), &lineRect, teJustCenter);
OffsetRect(&lineRect, 0 , 15);
TextBox(line7, strlen(line7), &lineRect, teJustCenter);
PenNormal();
PenMode(patXor);
x[0] = x[2] = 50;
x[1] = x[3] = 10;
y[0] = y[2] = 45;
y[1] = y[3] = 55;
vx[0] = vx[2] = 2;
vx[1] = vx[3] = -4;
vy[0] = vy[2] = 3;
vy[1] = vy[3] = -1;
count = 20;
creditRect = creditWPtr->portRect;
creditRect.right = 100;
MoveTo((int) x[0],(int) y[0]);
LineTo((int) x[1],(int) y[1]);
iticks = TickCount();
do
{
if (count)
for (i=0;i<=1;i++)
{
x[i] += vx[i];
if (x[i] < creditRect.left + 5)
vx[i] = (vx[i] > 0) ? vx[i] : -vx[i];
else if (x[i] > creditRect.right - 5)
vx[i] = (vx[i] < 0) ? vx[i] : -vx[i];
y[i] += vy[i];
if (y[i] < creditRect.top + 5)
vy[i] = (vy[i] > 0) ? vy[i] : -vy[i];
else if (y[i] > creditRect.bottom - 5)
vy[i] = (vy[i] < 0) ? vy[i] : -vy[i];
count--;
}
else
for (i=0;i<=3;i++)
{
x[i] += vx[i];
if (x[i] < creditRect.left + 5)
vx[i] = (vx[i] > 0) ? vx[i] : -vx[i];
else if (x[i] > creditRect.right - 5)
vx[i] = (vx[i] < 0) ? vx[i] : -vx[i];
y[i] += vy[i];
if (y[i] < creditRect.top + 5)
vy[i] = (vy[i] > 0) ? vy[i] : -vy[i];
else if (y[i] > creditRect.bottom - 5)
vy[i] = (vy[i] < 0) ? vy[i] : -vy[i];
}
MoveTo((int) x[0],(int) y[0]);
LineTo((int) x[1],(int) y[1]);
if (!count)
{
MoveTo((int) x[2],(int) y[2]);
LineTo((int) x[3],(int) y[3]);
}
WaitNextEvent(everyEvent,&theEvent,0L,0L);
Delay(1L,&finalTicks);
if (theEvent.what==updateEvt && theEvent.message==(long) creditWPtr)
goto MAIN;
} while (theEvent.what != keyDown && theEvent.what != mouseDown && !(doWait && TickCount() > iticks + doWait));
DisposeWindow(creditWPtr);
SetPort(oldPort);
}